<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddSomeColumnsToLogisticsTemplates extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('logistics_templates', function (Blueprint $table) {
            $table->boolean('open_weight')->default(true)->comment('是否开启: 按照重量计算');
            $table->unsignedTinyInteger('first_weight')->nullable()->comment('首重(kg)')->default(0);
            $table->decimal('first_weight_price')->nullable()->comment('首重运费(元)')->default(0);
            $table->unsignedTinyInteger('other_weight')->nullable()->comment('续重(kg)')->default(0);
            $table->decimal('other_weight_price')->nullable()->comment('续件运费(元)')->default(0);
            $table->boolean('open_volume')->default(true)->comment('是否开启: 按照重量计算');
            $table->unsignedTinyInteger('first_volume')->nullable()->comment('首体积量(m³)')->default(0);
            $table->decimal('first_volume_price')->nullable()->comment('首体积运费(元)')->default(0);
            $table->unsignedTinyInteger('other_volume')->nullable()->comment('首体积量(m³)')->default(0);
            $table->decimal('other_volume_price')->nullable()->comment('续体积运费(元)')->default(0);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('logistics_templates', function (Blueprint $table) {
            $table->dropColumn('open_weight');
            $table->dropColumn('first_weight');
            $table->dropColumn('first_weight_price');
            $table->dropColumn('other_weight');
            $table->dropColumn('other_weight_price');

            $table->dropColumn('open_volume');
            $table->dropColumn('first_volume');
            $table->dropColumn('first_volume_price');
            $table->dropColumn('other_volume');
            $table->dropColumn('other_volume_price');
        });
    }
}
